import { IUILogicNodeProvider } from '@ibiz-template/runtime';
import { IDEUIPFPluginLogic } from '@ibiz/model-core';

export class ParseSelectProvider implements IUILogicNodeProvider {
  async exec(model: IDEUIPFPluginLogic, ctx: IData): Promise<unknown> {
    const { data, params } = ctx;
    if (params && params.selectdataids) {
      params.selectdataids = data
        .map((_data: IData) => {
          const tempData = _data;
          tempData.srfkey = _data.id;
          return tempData.id;
        })
        .join(',');
    }
    return Promise.resolve();
  }
}
